package com.wwinsoft.framework.entity.security;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * @author: Tim Chen
 * @since 1.0
 */
@Embeddable
public class RoleAuthorityPK implements Serializable{

    private Long roleId;
    private Long authorityId;

    public RoleAuthorityPK() {
    }

    public RoleAuthorityPK(Long roleId, Long authorityId) {
        this.roleId = roleId;
        this.authorityId = authorityId;
    }

    @Column(name = "ROLE_ID")
    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    @Column(name = "AUTHORITY_ID")
    public Long getAuthorityId() {
        return authorityId;
    }

    public void setAuthorityId(Long authorityId) {
        this.authorityId = authorityId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof RoleAuthorityPK)) {
            return false;
        }

        RoleAuthorityPK that = (RoleAuthorityPK) o;

        if (authorityId != null ? !authorityId.equals(that.authorityId) : that.authorityId != null) {
            return false;
        }
        if (roleId != null ? !roleId.equals(that.roleId) : that.roleId != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = roleId != null ? roleId.hashCode() : 0;
        result = 31 * result + (authorityId != null ? authorityId.hashCode() : 0);
        return result;
    }
}
